#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;

int findPeakElement(int* nums, int numsSize) {
    int left = 0, right = numsSize - 1;
    while (left < right)
    {
        int mid = left + (right - left) / 2;
        if (nums[mid + 1] > nums[mid])
        {
            left = mid + 1;
        }
        else if (nums[mid + 1] <= nums[mid])
        {
            right = mid;
        }
    }
    return left;
}

int main()
{
    int a[] = { 1,2,3,1 };
    int n = sizeof(a) / sizeof(a[0]);
    int index = findPeakElement(a, n);
    cout << a[index] << endl;
    return 0;
}